package StudyCode.summary.zipfile;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CopyFromAnInternetURLLocalFile {
	public static void main(String[] args) {
		Path copy_to = Paths.get("E:/Copy/test.jpg");
		URI u = URI.create("https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1558252003&di=d085c85bf965113b0f1dac1e73bf183f&src=http://f.hiphotos.baidu.com/zhidao/pic/item/d788d43f8794a4c240e9466f0ef41bd5ac6e39af.jpg");

		try (InputStream in = u.toURL().openStream()) {
			Files.copy(in, copy_to);
			System.out.println(" 从网络 URL 复制到本地文件成功");
		} catch (IOException e) {
			System.err.println(e);
		}

	}
}
